<?php

namespace app\beautiful\model\order;


use app\common\model\CommonModel;



class OrderGoodsModel extends CommonModel{

    protected  $name = 'beautiful_order_goods';

    protected  $pk   = 'order_goods_id';
    /**
     * 模型写入前事件（钩子函数）
     */
    public static function onBeforeInsert($model)
    {
        $model->set("add_time", date('Y-m-d H:i:s'));
        $model->set("add_ip", request()->ip());
    }
    public static function list($where,$order='',$page=0,$limit=0,$field='*'){
        $query = self::where($where)->field($field);
        $count = $query->count();
        $query = $query->order($order);
        if($page>0) $query = $query->page($page);
        if($limit>0) $query = $query->limit($limit);
        $list = $query->select()->toArray();
        foreach ($list as &$v){
            if($v['user_type']==2){

            }else if($v['user_type']==23){

            }
        }
        return compact('count','list');
    }
}

